<template>
  <div>
    <el-card style="overflow: inherit" class="mb20">
      <define-form @search="handleSearch" ref="defineForm" />
    </el-card>
    <el-card>
      <el-tooltip class="item" content="刷新" effect="dark" placement="top">
        <el-button size="small" class="fr" @click="handleSearch" icon="el-icon-refresh" />
      </el-tooltip>
      <el-tooltip class="item" content="新增" effect="dark" placement="top">
        <el-button
          size="small"
          class="fr mr10 mb20"
          type="primary"
          icon="el-icon-plus"
          v-if="$auth('eval:add')"
          @click="handleEdit('add', {})"
        />
      </el-tooltip>

      <define-table @edit="handleEdit" ref="defineTable" />
    </el-card>
    <define-modal ref="defineModal" @refresh="handleSearch({})" />
  </div>
</template>

<script>
import DefineForm from './DefineForm'
import DefineTable from './DefineTable'
import DefineModal from './DefineModal'

export default {
  components: {
    DefineForm,
    DefineTable,
    DefineModal
  },
  methods: {
    handleSearch(param) {
      this.$refs.defineTable.handleGetList(param)
    },
    handleEdit(bool, obj) {
      this.$refs.defineModal.edit(bool, obj)
    }
  }
}
</script>
